<!doctype html>
<html>
    <head>
        <meta charset="UTF-8"/>
        <title>添加品牌</title>
	    <link rel="stylesheet" type="text/css" href="/webapp/css/easyui.css">
	    <link rel="stylesheet" type="text/css" href="/webapp/css/icon.css">
      <link rel="stylesheet" type="text/css" href="/webapp/css/color.css">
      <link rel="stylesheet" type="text/css" href="/webapp/css/public.css">
	    <script type="text/javascript" src="/webapp/js/lib/jquery.min.js"></script>
	    <script type="text/javascript" src="/webapp/js/lib/jquery.easyui.min.js"></script>
	    <script type="text/javascript" src="/webapp/js/lib/ajaxfileupload.js"></script>
	    <script type="text/javascript" src="/webapp/js/common/config.js"></script>
    </head>
    <body class="easyui-layout">
       <div class="easyui-container-fluid">
          <div class="easyui-pannel" style="width:100%;border: none;">
            <div class="nav" id="nav"></div> 
            <div class="easyui-panel">
              <form id="ff" method="post">
                <div style="margin-bottom:20px">
                  <label for="" class="item-label">编码：</label>
                  <input class="easyui-textbox" type="text" name="code" data-options="required:true">
                  <label for="" class="item-label">名称：</label>
                  <input class="easyui-textbox" type="text" name="name" data-options="required:true">
                  <label for="" class="item-label">拼音：</label>
                  <input class="easyui-textbox" type="text" name="pinyin">
                </div>
                <div style="margin-bottom:20px">
                  <label for="" class="item-label">大写名：</label>
                  <input class="easyui-textbox" type="text" name="nameUpperCase">
                  <label for="" class="item-label">英文名：</label>
                  <input class="easyui-textbox" type="text" name="englishName">
                  <label for="" class="item-label">大写英文名：</label>
                  <input class="easyui-textbox" type="text" name="englishNameUpperCase">
                </div>
                <div style="margin-bottom:20px;">
                  <label for="" class="item-label">别名：</label>
                  <input type="text" name="alias" class="easyui-tagbox" value="" style="width:440px;height:120px;" multiline="true"/>
                </div>
                <div style="margin-bottom:20px;">
                   <label class="item-label">国内外：</label>
                  <select name="international" class="easyui-combobox" style="width:170px;" data-options="panelHeight:'auto'">
                    <option value="DOMESTIC">是</option>
                    <option value="FOREIGN">否</option>
                  </select> 
                  <label class="item-label">互联网：</label>
                  <select name="internet" class="easyui-combobox" style="width:170px;" data-options="panelHeight:'auto'">
                    <option value="true">是</option>
                    <option value="false">否</option>
                  </select> 
                  <label for="" class="item-label">客户品牌：</label>
                    <select name="custom" class="easyui-combobox" style="width:170px;" data-options="panelHeight:'auto'">
                    <option value="true">是</option>
                    <option value="false">否</option>
                  </select> 
                </div>
                <div style="margin-bottom:20px">
                    <label for="" class="item-label">集团：</label>
                    <input class="easyui-textbox" type="text" name="group"/>
                    <label for="" class="item-label">父品牌：</label>
                    <input type="text" name="parentBrandCode" class="easyui-textbox"/>
                </div>
                <div style="padding:5px 0;text-align:center;">
                    <a href="javascript:void(0)" class="easyui-linkbutton c8" onclick="submitForm()" style="width:80px">Submit</a>
                    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()" style="width:80px">Clear</a>
                </div>              
              </form>     
            </div>
          </div> 
       </div>  
    </body>
    <script type="text/javascript">
         var id = getQueryParameter("id");
        $(function(){
          setNav();
          if(id){
            $.ajax({
              url:config.url +"/brand",
              type:'get',
              data:{id:id},
              xhrFields:{withCredentials:true},
              success:function(data){
                //填充表单
                  if(data){
                      $("#ff").form("load",changeProperty2String(data.content[0]));
                  }   
              },
              error:function(){

              }
            });
          }
        });
         function submitForm(){
            $("#ff").form("submit",{
                  onSubmit:function(){
                    var valid = $(this).form('enableValidation').form('validate');
                    if(!valid)return false;
                    var brand = getFormData(document.getElementById("ff"));
                    var method = "POST";
                    if(id){
                      method = "PATCH";
                      brand.id = id;
                    }
                    $.ajax({
                       url:config.url+"/brand",
                       type:method,
                       data:JSON.stringify(brand),
                       dataType:'json',
                       contentType:'application/json;charset=UTF-8',
                       xhrFields:{withCredentials:true},
                       beforeSend:function(){
                            window.parent.window.load();
                       },
                       complete:function(){
                            window.parent.window.disLoad();
                       },
                       success:function(data){
                            //if(data){
                            $.messager.alert("提示","操作成功","info",function(){
                               window.location.href = "./list.html";
                            });
                            //}
                        },
                        error(XMLHttpRequest,textStatus,thrown){

                        }
                    });
                     return false;
                 }
            });
         }
         function clearForm(){
            $("#ff").form("reset");
         }
    </script>
</html>
